#pragma once
#include<sstream>

class suParamType
{
public:
	suParamType(){};

	suParamType(const string& strParamName){m_strParamName = strParamName;};
	virtual string ToString() const {return "";};

	virtual void   FromString(const string& strData) {};

	std::string GetParamName() const { return m_strParamName; }

	void SetParamName(std::string val) { m_strParamName = val; }
public:
	string m_strParamName;
};

class suParamString:public suParamType
{
public:
	std::string GetParamValue() const { return m_strParamValue; }

	void SetParamValue(std::string val) { m_strParamValue = val; }

	suParamString(const string& strParamName, const string& strparamValue):suParamType(strParamName)
	{
		SetParamValue(strparamValue);
	}

	virtual string ToString() const
	{
		return m_strParamValue;
	}

	virtual void   FromString(const string& strData) 
	{
		m_strParamValue = strData;
	}
public:
	string m_strParamValue;
};

class suParamInt:suParamType
{
public:
	int GetParamValue() const { return m_iParamValue; }

	void SetParamValue(int val) { m_iParamValue = val; }

	suParamInt(const string& strParamName, const int& iParamValue):suParamType(strParamName)
	{
		SetParamValue(iParamValue);
	}

	virtual string ToString() const
	{
		stringstream ss;
		ss<<GetParamValue();
		return ss.str();
	}

	virtual void   FromString(const string& strData) 
	{
		stringstream ss;
		ss<<strData;
		ss>>m_iParamValue;
	}
private:
	int m_iParamValue;
};

class suParamReal:suParamType
{
public:
	float GetParamValue() const { return m_fParamValue; }

	void SetParamValue(float val) { m_fParamValue = val; }

	suParamReal(const string& strParamName, const float& iParamValue):suParamType(strParamName)
	{
		SetParamValue(iParamValue);
	}

	virtual string ToString() const
	{
		stringstream ss;
		ss<<GetParamValue();
		return ss.str();
	}

	virtual void   FromString(const string& strData) 
	{
		stringstream ss;
		ss<<strData;
		ss>>m_fParamValue;
	}
private:
	float m_fParamValue;
};

class suParamData
{
	typedef list<suParamType> GroupParamType;
	typedef GroupParamType::iterator IteGroupParamType;
public:
	void AddData(const suParamType& param)
	{
		m_vParamData.push_back(param);
	};

	void RemoveData(const string& param)
	{
		IteGroupParamType pos;
		for(pos = m_vParamData.begin(); pos!= m_vParamData.end(); ++pos)
		{
			if(pos->GetParamName() == param) break;
		}

		if(pos != m_vParamData.end())
		{
			m_vParamData.erase(pos);
		}

	};

private:
	GroupParamType m_vParamData;
};

extern  void Parse(const string& str,suParamString& param);
